<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		
		
		$this->login->seguridadIndex();

		
		$error = 0;
		$registrar=0;
		
		
		if(isset($_POST['registrar']))
		{
		    $registrar = 1;
		    //$error = registrarUsuario(limpiar($_POST['user']), $_POST['pass']);
		   
		}
		else if(isset($_POST['login']))
		{      
		    $recordarme=0;
		    if(isset($_POST['recordarme'])) $recordarme=1;
		    $error = $this->login->login( $this->login->limpiar($_POST['user']), $_POST['pass'],$recordarme);
		    
		    if($error>0)
		    {
		        header("Location: ".base_url()."index.php/inicio");
		        exit();
		    }
		    
		}

		$data['error'] = $error;
		$data['registrar'] = $registrar;
		$this->load->view('login', $data);
	}


	public function template()
	{
		$this->load->view('template');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
